package com.shengcheng.consumer;

import com.alibaba.fastjson.JSON;
import com.shengcheng.constant.KafkaConstant;
import com.shengcheng.constant.SystemConstant;
import com.shengcheng.entity.AlbumStat;
import com.shengcheng.entity.TrackStat;
import com.shengcheng.service.OrderInfoService;
import com.shengcheng.vo.AlbumStatMqVo;
import com.shengcheng.vo.TrackStatMqVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;


@Component
public class OrderConsumer {
    @Autowired
    private OrderInfoService orderInfoService;
    //取消订单信息
    @KafkaListener(topics = KafkaConstant.QUEUE_ORDER_CANCEL)
    public void cancelOrder(Long orderId) {
       if(orderId!=null){
           orderInfoService.cancelOrder(orderId);
       }
    }
    //订单支付成功之后修改订单状态
    @KafkaListener(topics = KafkaConstant.PAY_ORDER_SUCCESS_QUEUE)
    public void updateOrderInfo(String orderNo) {
        if(!StringUtils.isEmpty(orderNo)){
            orderInfoService.afterPaySuccess(orderNo);
        }
    }
}

